﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Test
{
    /// <summary>
    /// Logique d'interaction pour MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {

        public MainWindow()
        {
            InitializeComponent();
        }

        private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            canvas.Children.Clear();
            Region region = new Region(30, 50);
            foreach (Area a in region.Areas)
            {
                foreach (Area next in a.Next)
                {
                    Line l = new Line();
                    l.X1 = a.Position.X;
                    l.Y1 = canvas.ActualHeight - a.Position.Y;
                    l.X2 = next.Position.X;
                    l.Y2 = canvas.ActualHeight - next.Position.Y;
                    l.Stroke = System.Windows.Media.Brushes.Black;
                    l.StrokeThickness = 3;
                    canvas.Children.Add(l);
                }

                Ellipse c = new Ellipse();
                
                c.Width = 20;
                c.Height = 20;
                c.Stroke = System.Windows.Media.Brushes.Black;
                switch (a.Type){
                    case AreaType.Start : c.Fill = System.Windows.Media.Brushes.Blue; break;
                    case AreaType.PreTown: c.Fill = System.Windows.Media.Brushes.Cyan; break;
                    case AreaType.Town: c.Fill = System.Windows.Media.Brushes.Green; break;
                    case AreaType.PostTown: c.Fill = System.Windows.Media.Brushes.Yellow; break;
                    case AreaType.End: c.Fill = System.Windows.Media.Brushes.Red; break;
                }
                
                Canvas.SetBottom(c, a.Position.Y - 10);
                Canvas.SetLeft(c, a.Position.X - 10);
                canvas.Children.Add(c);
            }
            
        }

    }
}
